package com.team233.zuccecho.controller;
import com.team233.zuccecho.rabbitMQ.ZuccEchoMessage;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("summary")
public class SummaryController {
    @Autowired
    private AmqpTemplate amqpTemplate;
    @Autowired
    private TopicExchange topicExchange;
    /**
    返回某班级共有的学生数
     */
    @GetMapping("feedback")
    public void SummaryFeedback(String time,String subject){
        System.out.println(time+subject);
        ZuccEchoMessage msgTime = new ZuccEchoMessage(ZuccEchoMessage.CATEGORY_STAT);
        msgTime.appendContent("msg", time);
        amqpTemplate.convertAndSend(topicExchange.getName(), "zucc.time.hour", msgTime);

        ZuccEchoMessage msgCollege = new ZuccEchoMessage(ZuccEchoMessage.CATEGORY_STAT);
        msgCollege.appendContent("msg", subject);
        amqpTemplate.convertAndSend(topicExchange.getName(), "zucc.college.js", msgCollege);
    }
}
